package org.example.sudoku;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;
import android.content.Intent;

public class Result extends Activity implements OnClickListener {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.result);
		
			Bundle b = getIntent().getExtras();
			String product = b.getString("content").toString();	
			TextView et1 = (TextView) findViewById(R.id.edit_text);
			EditText et2 = (EditText) findViewById(R.id.amount_text);
			et1.setText(product);
			//String amount = et2.getText().toString();

			View finishButton =findViewById(R.id.finish_button);
			finishButton.setOnClickListener(this);
			View nextButton =findViewById(R.id.next_button);
		    nextButton.setOnClickListener(this);
	
		}
		public void onClick(View v) {
			switch (v.getId()) {

			case R.id.finish_button:
				
				ArrayList<String> resultList = new ArrayList<String>();
				resultList.add("windows");
				resultList.add("linux");
				resultList.add("macos");
				
                Intent getListIntent = new Intent();

                Bundle b = new Bundle();
                
    			b.putStringArrayList("key", resultList);
    			
    			getListIntent.putExtras(b);
                
                setResult(RESULT_OK,getListIntent);
				
				finish();
			
			break;
			case R.id.next_button:
				Intent intent2 = new Intent("com.google.zxing.client.android.SCAN");
				intent2.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "ONE_D_MODE");
				startActivityForResult(intent2, 0);
				
			break;

			}
		}
		public void onActivityResult(int requestCode, int resultCode, Intent intent) {
		    if (requestCode == 0) {
		        if (resultCode == RESULT_OK) {
		            String contents = intent.getStringExtra("SCAN_RESULT");
		            // Handle successful scan
					Intent result = new Intent(this.getApplicationContext(),Result.class);
					Bundle b = new Bundle();
					b.putString("content",contents);
					result.putExtras(b);
					startActivityForResult(result, 0);
					finish(); // NEW FINISH
		        } else if (resultCode == RESULT_CANCELED) {
		            // Handle can
		        }
		    }
		}
	

		
	
}
